home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / NMK / Recorders / ButtonCellCover.m < prev    next >
Text File  |  1995-06-12  |  1KB  |  69 lines

  1. /***** ButtonCellCover.m -- ButtonCellCover object implementation
  2.     NeXTstep Measurement Kit
  3.     by Alex Meyer <ameyer@phoenix.Princeton.EDU>
  4.     for computer science senior thesis
  5.     23 April 1992 -- created from RButtonCell.m
  6.     24 April 1992 -- used named object to trigger initialization
  7. *****/
  8.  
  9. #import <sys/time.h>
  10. #import <appkit/Application.h>
  11. #import "RButtonVars.h"
  12. #import "ButtonCellCover.h"
  13.  
  14. #define VARSNAME ("ButtonVars")
  15.  
  16. #define MICRO (1000000.0)
  17. #define DOUBLETIME(stv) ((double) (((unsigned long) (stv).tv_sec) \
  18.     + (((unsigned long) (stv).tv_usec) / MICRO)))
  19.  
  20. @implementation ButtonCellCover
  21.  
  22. - makeVarsRect:(const NXRect *)rect
  23. {
  24.     id vars;
  25.  
  26.     vars = [RButtonVars alloc];
  27.     [vars initString:contents
  28.         tag:tag
  29.         rect:rect];
  30.     NXNameObject(VARSNAME,vars,self);
  31.     return (vars);
  32. }
  33.  
  34.  
  35.  
  36. - (BOOL)trackMouse:(NXEvent *)theEvent
  37.     inRect:(const NXRect *)cellFrame
  38.     ofView:controlView
  39. {
  40.     id vars;
  41.     BOOL res;
  42.     double time0,time1;
  43.     struct timeval start,finish;
  44.     struct timezone zone;
  45.  
  46.     gettimeofday(&start,&zone);
  47.     res = [super trackMouse:theEvent
  48.         inRect:cellFrame
  49.         ofView:controlView];
  50.     gettimeofday(&finish,&zone);
  51.     time0 = DOUBLETIME(start);
  52.     time1 = DOUBLETIME(finish);
  53.     vars = NXGetNamedObject(VARSNAME,self);
  54.     if (!(vars))
  55.         vars = [self makeVarsRect:cellFrame];
  56.     [vars incHits];
  57.     if (!(res))
  58.         [vars incCancel];
  59.     [vars timeFrom:time0
  60.         to:time1];
  61.     return (res);
  62. }
  63.  
  64. @end
  65.  
  66. #undef DOUBLETIME
  67. #undef MICRO
  68. #undef VARSNAME
  69.